<%@ page language = "java" import = "java.util.*" %>
<%@ page import = "edu.colorado.karl.manctrl.ManualControl" %>

<html>
<head>
<title>IntelliCore - Manual Control</title>
<link rel="stylesheet" type="text/css" media="screen" charset="utf-8" href="css/common.css"/>
</head>
<body>

<%@ include file = "header.jspf" %>

<table border="0">
  <tr>
    <th align="center" colspan="3">
    <h1>Manual Control</h1>
    </th>
  </tr>
  <tr>
    <td colspan="3">
      <br>Users can change temperature set points here. All figures are in degrees Fahrenheit.
    </td>
  </tr>
  <tr>
    <td align="center" valign="center" height="20%">

<h3>Room Temperature</h3>
<table border="0">
  <tr>
    <th><b>Zone</b></th>
    <th><b>Setpoint</b></th>
    <th><b>+/-</b></th>
  </tr>
  <tr>
    <td align=center>Entire House</td>

<%

ManualControl mc = ManualControl.getManualControl();
int roomTemp = -1;
int roomRange = -1;
int hotTank = -1;
int hotTankRange = -1;
int coldTank = -1;
int coldTankRange = -1;
String autoChecked = "";
String manualChecked = "";
String heatingChecked = "";
String coolingChecked = "";

if(access_level < 1)
{

%>

  <BR>Error, you must login to view this page.
  <meta http-equiv="REFRESH" content="0";url="error_login_required.jsp">

<%

}

if(mc.getHeatingCoolingMode())
{
  coolingChecked = "checked";
  heatingChecked = "";
}
else
{
  heatingChecked = "checked";
  coolingChecked = "";
}

if(mc.getTankMode())
{
  autoChecked = "checked";
  manualChecked = "";
}
else
{
  manualChecked = "checked";
  autoChecked = "";
}

roomTemp = mc.getSetpoint("roomTemp");
roomRange = mc.getSetpoint("roomRange");
hotTank = mc.getSetpoint("hotTank");
hotTankRange = mc.getSetpoint("hotTankRange");
coldTank = mc.getSetpoint("coldTank");
coldTankRange = mc.getSetpoint("coldTankRange");

out.println("<form action='change_setpoints.jsp' method='post'>");
out.println("<td align='center'><input type='text' size='3' name='roomTemp' value='" + 
  roomTemp + "'></td>");
out.println("<td align='center'><input type='text' size='3' name='roomRange' value='" + 
  roomRange + "'></td></tr>");

%>

<%-- to ensure proper spacing...
<tr><td colspan = '3' align = 'center'><font color = 'white'>-</font></td></tr> --%>

</tr>
</table>

<%
out.println("<br><b>Heating/Cooling Mode:</b> <input type='radio' name='hc_mode' value='heating'" + 
  heatingChecked + "> Heating <input type='radio' name='hc_mode' value='cooling'" + 
  coolingChecked + "> Cooling");
%>
    </td>
    <td width=10%></td>
    <td align=center valign=center height=20%>
    <spacer type=vertical size=50>

<h3>Tank Temperature</h3>
<table border='0'>
  <tr>
    <th><b>Tank</b></th>
    <th><b>Setpoint</b></th>
    <%-- <th><b>Range</b></th> --%>
  </tr>
<tr>
  <td align='center'>Hot Tank</td>

<%

out.println("<td align='center'><input type='text' size='3' name='hotTank' value='" 
  + hotTank + "'></td>");

%>

  <tr>
    <td align='center'>Cold Tank</td>

<%

out.println("<td align='center'><input type='text' size='3' name='coldTank' value='" +
  coldTank + "'></td>");
out.println("</table>");
out.println("<b>Tank control mode:</b> <input type='radio' name='tank_mode' value='tank_auto'" +
  autoChecked + "> Automatic <input type='radio' name='tank_mode' value='tank_manual'" + 
  manualChecked + "> Manual<br>");

%>

</td>
</tr>
<tr>
<td align = 'center' colspan = '3'>
<br><input type='submit' value='Apply Changes'>
<input type='reset' value='Cancel Changes'>
</td>
</form>

    </td>
  </tr>
</table>
</body>
</html>
